package cn.hrlly.tao2shou.presenter;

import cn.hrlly.tao2shou.biz.SubmitApplicationBiz;
import cn.hrlly.tao2shou.biz.SubmitApplicationBizImpl;
import cn.hrlly.tao2shou.domain.Application;
import cn.hrlly.tao2shou.listener.OnSubmitApplicationListener;
import cn.hrlly.tao2shou.view.view_interface.SubmitApplicationView;

/**
 * User: gengliang
 * Date: 2016-01-30
 * Time: 16:43
 */

public class SubmitApplicationPresenterImpl implements SubmitApplicationPresenter,OnSubmitApplicationListener {

    private SubmitApplicationBiz submitApplicationBiz;
    private SubmitApplicationView submitApplicationView;

    public SubmitApplicationPresenterImpl(SubmitApplicationView submitApplicationView){
        this.submitApplicationBiz=new SubmitApplicationBizImpl(this);
        this.submitApplicationView=submitApplicationView;
    }

    @Override
    public void submitApplicationPresenter() {
        Application application=new Application();
        application.setReleaseId(submitApplicationView.getReleaseId());
        application.setExpectedPrice(submitApplicationView.getExpectedPrice());
        application.setTradeTime(submitApplicationView.getTradeTime());
        application.setTradeLocation(submitApplicationView.getTradeLocation());
        application.setPublisherId(submitApplicationView.getPublisherId());
        application.setBarterName(submitApplicationView.getBarterName());
        application.setBarterDescription(submitApplicationView.getBarterDescription());
        submitApplicationBiz.submitApplication(application,submitApplicationView.getBarterPhotos());
    }

    @Override
    public void submitApplicationSucc(String message) {
        submitApplicationView.showMessage(message);
        submitApplicationView.finishActivity();
    }

    @Override
    public void submitApplicationSucc(int message) {
        submitApplicationView.showMessage(message);
        submitApplicationView.finishActivity();
    }

    @Override
    public void submitApplicationFail(String errorMessage) {
        submitApplicationView.showMessage(errorMessage);
    }

    @Override
    public void submitApplicationFail(int errorMessage) {
        submitApplicationView.showMessage(errorMessage);
    }
}
